import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  SetMetadata,
} from '@nestjs/common';
import { ResultService } from './result.service';
import { CreateResultDto } from './dto/create-result.dto';

@Controller('result')
export class ResultController {
  constructor(private readonly resultService: ResultService) {}

  @Post('create')
  @SetMetadata('require-login', true)
  create(@Body() createResultDto: CreateResultDto) {
    return this.resultService.create(createResultDto);
  }

  @Get('list')
  @SetMetadata('require-login', true)
  findAll() {
    return this.resultService.list();
  }

  @Get('findByUserId/:userId')
  @SetMetadata('require-login', true)
  findByUserId(@Param('userId') userId: string) {
    return this.resultService.findByUserId(+userId);
  }
}
